feat(vmem): fold space_aware_map dispatch#1419
Conversation
Fixes: hyperlight-dev#1409 Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Hyperlight’s virtual-memory (vmem) multi-space page-table rebuild interface to be more architecture-specific and to centralize SpaceAwareMapping handling inside hyperlight_common::vmem, aligning with issue #1409.
Changes:
- Moves
SpaceReferenceMappingto be per-architecture (withVoidused on arches that never emitAnotherSpace), and replaces i686’s genericdepthwith an i686-specificSharedTableLevelenum. - Changes
vmem::space_aware_mapto takeSpaceAwareMappingand dispatch internally to eitherarch::maporarch::link_shared_table. - Updates snapshot rebuild code to call the unified
vmem::space_aware_mapAPI for bothThisSpaceandAnotherSpacecases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_host/src/sandbox/snapshot.rs | Updates snapshot rebuild loop to use the new unified vmem::space_aware_map API. |
| src/hyperlight_common/src/vmem.rs | Re-exports per-arch SpaceReferenceMapping and adds a wrapper space_aware_map that dispatches internally. |
| src/hyperlight_common/src/arch/i686/vmem.rs | Introduces SharedTableLevel + i686 SpaceReferenceMapping and renames the link operation to link_shared_table. |
| src/hyperlight_common/src/arch/amd64/vmem.rs | Defines SpaceReferenceMapping = Void and implements statically-unreachable link_shared_table for amd64. |
| src/hyperlight_common/src/arch/aarch64/vmem.rs | Defines SpaceReferenceMapping = Void and implements statically-unreachable link_shared_table for aarch64. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Tomasz Andrzejak <andreiltd@users.noreply.github.com>
jsturtevant
left a comment
There was a problem hiding this comment.
Maybe @danbugs @syntactically should take a look too
| /// around the page tables being written, and must invalidate TLBs | ||
| /// afterwards if they were live. | ||
| pub use arch::space_aware_map; | ||
| pub unsafe fn space_aware_map<Op: TableOps>( |
There was a problem hiding this comment.
I think it maybe makes sense for this to live inside the arch directory still. One of the benefits of this refactor is that it may be more compact/cleaner to implement both functions as part of a single function that does the page table traversal.
|
@andreiltd is this still needed after #1525 ? |
Fixes: #1409